import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

public class Demo3 {
    public static void main(String[] args) throws IOException {
        Reader reader = new FileReader("d:/text.txt");
        while(true){
            int n = reader.read();
            if(n == -1){
                break;
            }
            char ch = (char) n;
            System.out.println(n);
        }

        /*while(true){
            char[] ret = new char[10];
            int n = reader.read(ret);
            if(n == -1){
                break;
            }
            for (int i = 0; i < n; i++) {
                System.out.println(ret[i]);
            }
        }
        reader.close();//关闭操作

        try{
            while(true){
                char[] ret = new char[10];
                int n = reader.read(ret);
                if(n == -1){
                    break;
                }
                for (int i = 0; i < n; i++) {
                    System.out.println(ret[i]);
                }
            }
        }finally {
            reader.close();//关闭操作
        }

        try(Reader reader1 = new FileReader("")){//实现 closeable接口，流对象都可以
            while(true){
                char[] ret = new char[10];
                int n = reader.read(ret);
                if(n == -1){
                    break;
                }
                for (int i = 0; i < n; i++) {
                    System.out.println(ret[i]);
                }
            }
        }*/
    }
}
